﻿using System;
using Character;
using UnityEngine;

// Token: 0x0200015E RID: 350
public class WearObj
{
	// Token: 0x0600090F RID: 2319 RVA: 0x00034BE8 File Offset: 0x00032DE8
	public WearObj(WearParameter wearParam, WEAR_TYPE type, GameObject obj, WearData data)
	{
		this.obj = obj;
		this.wearParam = wearParam;
		this.type = type;
		this.uv_normal = obj.GetComponent<UVNormalBlend>();
		this.SetupMaterials(data);
		this.SetupShow();
	}

	// Token: 0x17000126 RID: 294
	// (get) Token: 0x06000910 RID: 2320 RVA: 0x00034C20 File Offset: 0x00032E20
	public int ShowUpperNum
	{
		get
		{
			return this.showUpper;
		}
	}

	// Token: 0x17000127 RID: 295
	// (get) Token: 0x06000911 RID: 2321 RVA: 0x00034C28 File Offset: 0x00032E28
	public int ShowLowerNum
	{
		get
		{
			return this.showLower;
		}
	}

	// Token: 0x06000912 RID: 2322 RVA: 0x00034C30 File Offset: 0x00032E30
	private void SetupMaterials(WearData data)
	{
		int num = (int)this.type;
		this.materialCustom = this.obj.GetComponent<MaterialCustoms>();
		this.enableColorCustom = (this.materialCustom != null);
		this.hasSecondColor = false;
		this.hasSecondSpecular = false;
		if (this.enableColorCustom)
		{
			for (int i = 0; i < this.materialCustom.datas.Length; i++)
			{
				if (this.materialCustom.datas[i].param.name.IndexOf("Sub") >= 0)
				{
					this.hasSecondColor = true;
				}
				if (this.materialCustom.datas[i].param.name.IndexOf("SubMetallic") >= 0)
				{
					this.hasSecondColor = true;
					this.hasSecondSpecular = true;
					break;
				}
			}
			if (this.wearParam.wears[num] == null)
			{
				this.wearParam.wears[num].color = new ColorParameter_PBR2();
			}
		}
		else
		{
			this.wearParam.wears[num].color = null;
		}
	}

	// Token: 0x06000913 RID: 2323 RVA: 0x00034D48 File Offset: 0x00032F48
	private void SetupShow()
	{
		if (this.type == WEAR_TYPE.TOP)
		{
			this.showUpper = this.SetupShow(WEAR_SHOW_TYPE.TOPUPPER);
			this.showLower = this.SetupShow(WEAR_SHOW_TYPE.TOPLOWER);
		}
		else if (this.type == WEAR_TYPE.SWIM)
		{
			this.showUpper = this.SetupShow(WEAR_SHOW_TYPE.SWIMUPPER);
			this.showLower = this.SetupShow(WEAR_SHOW_TYPE.SWIMLOWER);
		}
		else if (this.type == WEAR_TYPE.SWIM_TOP)
		{
			this.showUpper = this.SetupShow(WEAR_SHOW_TYPE.SWIM_TOPUPPER);
			this.showLower = this.SetupShow(WEAR_SHOW_TYPE.SWIM_TOPLOWER);
		}
		else
		{
			WEAR_SHOW_TYPE showType = Wears.WeatToShowType[(int)this.type];
			this.showUpper = this.SetupShow(showType);
			this.showLower = 0;
		}
	}

	// Token: 0x06000914 RID: 2324 RVA: 0x00034DF8 File Offset: 0x00032FF8
	private int SetupShow(WEAR_SHOW_TYPE showType)
	{
		if (this.type == WEAR_TYPE.GLOVE || this.type == WEAR_TYPE.SOCKS || this.type == WEAR_TYPE.SHOES)
		{
			return 1;
		}
		Transform transform = null;
		Transform transform2 = null;
		string text = WearObj.ShowRoots[(int)showType, 0];
		string text2 = WearObj.ShowRoots[(int)showType, 1];
		if (text != null)
		{
			transform = Transform_Utility.FindTransform(this.obj.transform, text);
		}
		if (text2 != null)
		{
			transform2 = Transform_Utility.FindTransform(this.obj.transform, text2);
		}
		if (transform == null && transform2 != null)
		{
			GlobalData.Debug_LogError("明明没有衣服穿\u3000有半脱的衣服？");
		}
		int num = 0;
		if (transform != null)
		{
			num++;
		}
		if (transform2 != null)
		{
			num++;
		}
		if (Wears.IsLower(showType))
		{
			this.lowerAll = ((!(transform != null)) ? null : transform.gameObject);
			this.lowerHalf = ((!(transform2 != null)) ? null : transform2.gameObject);
		}
		else
		{
			this.upperAll = ((!(transform != null)) ? null : transform.gameObject);
			this.upperHalf = ((!(transform2 != null)) ? null : transform2.gameObject);
		}
		if (num == 0 && this.type == WEAR_TYPE.PANST)
		{
			return 1;
		}
		return num;
	}

	// Token: 0x06000915 RID: 2325 RVA: 0x00034F68 File Offset: 0x00033168
	public void UpdateColorCustom()
	{
		int num = (int)this.type;
		if (!this.enableColorCustom)
		{
			return;
		}
		if (this.wearParam.wears[num].color == null)
		{
			this.wearParam.wears[num].color = new ColorParameter_PBR2(this.materialCustom);
		}
		else
		{
			this.wearParam.wears[num].color.SetMaterialCustoms(this.materialCustom);
		}
	}

	// Token: 0x06000916 RID: 2326 RVA: 0x00034FE0 File Offset: 0x000331E0
	public bool HasLowerShow()
	{
		return this.showLower != 0;
	}

	// Token: 0x06000917 RID: 2327 RVA: 0x00034FF0 File Offset: 0x000331F0
	public bool HasUpperHalf()
	{
		return this.upperHalf != null;
	}

	// Token: 0x06000918 RID: 2328 RVA: 0x00035000 File Offset: 0x00033200
	public bool HasLowerHalf()
	{
		return this.lowerHalf != null;
	}

	// Token: 0x06000919 RID: 2329 RVA: 0x00035010 File Offset: 0x00033210
	public bool HasShow(WEAR_SHOW_TYPE showType)
	{
		if (Wears.IsLower(showType))
		{
			return this.showLower != 0;
		}
		return this.showUpper != 0;
	}

	// Token: 0x0600091A RID: 2330 RVA: 0x00035038 File Offset: 0x00033238
	public void ChangeShow_Upper(WEAR_SHOW show)
	{
		if (this.showUpper == 0)
		{
			return;
		}
		if (this.upperAll != null)
		{
			this.upperAll.SetActive(show == WEAR_SHOW.ALL);
		}
		if (this.upperHalf != null)
		{
			this.upperHalf.SetActive(show == WEAR_SHOW.HALF);
		}
	}

	// Token: 0x0600091B RID: 2331 RVA: 0x00035094 File Offset: 0x00033294
	public void ChangeShow_Lower(WEAR_SHOW show)
	{
		if (this.showLower == 0)
		{
			return;
		}
		if (this.lowerAll != null)
		{
			this.lowerAll.SetActive(show == WEAR_SHOW.ALL);
		}
		if (this.lowerHalf != null)
		{
			this.lowerHalf.SetActive(show == WEAR_SHOW.HALF);
		}
	}

	// Token: 0x0600091C RID: 2332 RVA: 0x000350F0 File Offset: 0x000332F0
	public void SetLiquidShow(int[] sperms)
	{
		bool flag = this.upperAll != null && this.upperAll.activeSelf;
		bool flag2 = this.upperHalf != null && this.upperHalf.activeSelf;
		bool flag3 = this.lowerAll != null && this.lowerAll.activeSelf;
		bool flag4 = this.lowerHalf != null && this.lowerHalf.activeSelf;
		if (this.lowerAll == null)
		{
			flag3 = flag;
			flag4 = flag2;
		}
		if (this.liquid != null)
		{
			this.liquid.SetShow(flag, flag2, flag3, flag4, sperms);
		}
	}

	// Token: 0x0600091D RID: 2333 RVA: 0x000351B0 File Offset: 0x000333B0
	// Note: this type is marked as 'beforefieldinit'.
	static WearObj()
	{
		string[,] array = new string[14, 2];
		array[0, 0] = "N_top_a";
		array[0, 1] = "N_top_b";
		array[1, 0] = "N_bot_d";
		array[1, 1] = "N_bot_n";
		array[2, 0] = "N_bot_d";
		array[2, 1] = "N_bot_n";
		array[3, 0] = "cf_O_bra_d";
		array[3, 1] = "cf_O_bra_n";
		array[4, 0] = "cf_O_shorts_d";
		array[4, 1] = "cf_O_shorts_n";
		array[5, 0] = "N_top_a";
		array[5, 1] = "N_top_b";
		array[6, 0] = "N_bot_a";
		array[6, 1] = "N_bot_b";
		array[7, 0] = "N_top_a";
		array[7, 1] = "N_top_b";
		array[8, 0] = "N_bot_d";
		array[8, 1] = "N_bot_n";
		array[9, 0] = "N_bot_a";
		array[9, 1] = "N_bot_b";
		array[11, 0] = "N_panst_d";
		array[11, 1] = "N_panst_n";
		WearObj.ShowRoots = array;
	}

	// Token: 0x040008D8 RID: 2264
	public static readonly string[,] ShowRoots;

	// Token: 0x040008D9 RID: 2265
	public GameObject obj;

	// Token: 0x040008DA RID: 2266
	public MaterialCustoms materialCustom;

	// Token: 0x040008DB RID: 2267
	public bool enableColorCustom;

	// Token: 0x040008DC RID: 2268
	public bool hasSecondColor;

	// Token: 0x040008DD RID: 2269
	public bool hasSecondSpecular;

	// Token: 0x040008DE RID: 2270
	public UVNormalBlend uv_normal;

	// Token: 0x040008DF RID: 2271
	private WearParameter wearParam;

	// Token: 0x040008E0 RID: 2272
	private WEAR_TYPE type;

	// Token: 0x040008E1 RID: 2273
	private int showUpper;

	// Token: 0x040008E2 RID: 2274
	private int showLower;

	// Token: 0x040008E3 RID: 2275
	private GameObject upperAll;

	// Token: 0x040008E4 RID: 2276
	private GameObject upperHalf;

	// Token: 0x040008E5 RID: 2277
	private GameObject lowerAll;

	// Token: 0x040008E6 RID: 2278
	private GameObject lowerHalf;

	// Token: 0x040008E7 RID: 2279
	public WearLiquidObj liquid;
}
